package com.ict.txmsv2.utils;

import com.ict.txmsv2.model.User;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @author yoleen
 * @date 2020/2/29 17:10
 */


public class UserUtils {
    public static User getCurrentHr(){
        SecurityContext context = SecurityContextHolder.getContext();
        Authentication authentication = context.getAuthentication();
        if(authentication==null){
            return null;
        }
        Object principal = authentication.getPrincipal();
        return ((User) principal);
    }
}
